var wpWidgetOpts;!function(t){var e=t(document);wpWidgetOpts={hoveredSidebar:null,init:function(){var s=this,i=t(".wp-admin.widgets-php .wrap a.page-title-action"),o=t(".extended-widget-opts-tabs"),d=t(".widgetsopts-chooser"),n=d.find(".widgetopts-chooser-sidebars");o.length>0&&s.loaded("","loaded"),t(".widget-liquid-right .widget, .inactive-sidebar .widget, #accordion-panel-widgets .customize-control-widget_form").each(function(){s.loaded("","loaded")}),e.on("widget-added",function(t,e){s.loaded(e,"added")}),e.on("widget-updated",function(t,e){s.loaded(e,"updated")}),e.on("click",".extended-widget-opts-inner-lists h4",function(){var e=t(this).attr("id");t(".extended-widget-opts-inner-lists ."+e).slideToggle(250)}),e.on("click",".widget-opts-toggler-note",function(e){t(this).parent("p").parent(".widget-opts-logic").find(".widget-opts-toggle-note").slideToggle(250),e.preventDefault(),e.stopPropagation()}),i.length>0&&i.after('<a href="'+widgetopts10n.opts_page+'" class="page-title-action hide-if-no-customize widgetopts-super">'+widgetopts10n.translation.manage_settings+"</a>"),s.live_search(),t(".widget-control-actions .alignleft .widget-control-remove").after(widgetopts10n.controls),s.do_chooser(d,n),s.sidebarOptions(),s.removeSidebarWidgets()},loaded:function(e,s){var i,o=0,d=0,n=0,a=0,r=0,c=!1,l=".extended-widget-opts-tabs",p=".extended-widget-opts-styling-tabs",g=".extended-widget-opts-visibility-m-tabs",h=".extended-widget-opts-visibility-tabs",w=".extended-widget-opts-settings-tabs",f="#extended-widget-opts-selectedtab",v="#extended-widget-opts-visibility-m-selectedtab",b="#extended-widget-opts-visibility-selectedtab",u="#extended-widget-opts-settings-selectedtab";"undefined"!=typeof wp&&(c="undefined"!=typeof wp.customize),""!=e&&(i="#"+e.attr("id"),t(i).find(f).length>0&&(o=t("#"+e.attr("id")).find(f).val(),o=parseInt(o)),t(i).find(b).length>0&&(a=t("#"+e.attr("id")).find(b).val(),a=parseInt(a)),t(i).find(v).length>0&&(n=t("#"+e.attr("id")).find(v).val(),n=parseInt(n)),t(i).find(u).length>0&&(r=t("#"+e.attr("id")).find(u).val(),r=parseInt(r))),"added"==s&&(o=0,n=0,a=0,r=0),""!=e?(t(i).find(l).length>0&&t(i).find(l).tabs({active:o}),t(i).find(g).length>0&&t(i).find(g).tabs({active:n}),t(i).find(h).length>0&&t(i).find(h).tabs({active:a}),t(i).find(w).length>0&&t(i).find(w).tabs({active:r})):(t(l).tabs({active:o}),t(p).tabs({active:d}),t(g).tabs({active:n}),t(h).tabs({active:a}),t(w).tabs({active:r})),t(l).click("tabsselect",function(){t(this).find(f).length>0&&t(this).find(f).val(t(this).tabs("option","active"))}),t(h).click("tabsselect",function(){t(this).find(b).length>0&&t(this).find(b).val(t(this).tabs("option","active"))}),t(g).click("tabsselect",function(){t(this).find(v).length>0&&t(this).find(v).val(t(this).tabs("option","active"))}),t(w).click("tabsselect",function(){t(this).find(u).length>0&&t(this).find(u).val(t(this).tabs("option","active"))})},live_search:function(){"undefined"!=typeof t.fn.liveFilter&&t("#widgetopts-widgets-search").length>0&&(t(".widget:last-of-type").after('<div class="widgetopts-separator" />'),t("#widgets-left .widget").each(function(){var e=t(this).index()+1;t(this).attr("data-widget-index",e)}),t("#widgets-left").liveFilter("#widgetopts-widgets-search",".widget",{filterChildSelector:".widget-title h4, .widget-title h3",after:function(e,s){s.each(function(){t(this).insertAfter(t(this).parent().find(".widgetopts-separator"))}),e.sort(function(t,e){return t.getAttribute("data-widget-index")-e.getAttribute("data-widget-index")}),e.each(function(){t(this).insertBefore(t(this).parent().find(".widgetopts-separator"))})}}),t("#wpbody-content").on("keyup",".widgetopts-widgets-search",function(){p=t(this).parent().find(".widgetopts-clear-results"),""!==t(this).val()?p.addClass("widgetopts-is-visible"):p.removeClass("widgetopts-is-visible")}),t("#wpbody-content").on("click",".widgetopts-clear-results",function(e){return s=t(this).parent().find(".widgetopts-widgets-search"),s.val("").focus().trigger("keyup"),"widgetopts-search-chooser"==s.attr("id")?t(".widgets-chooser-sidebars li:not(:first)").removeClass("widgets-chooser-selected"):s.hasClass("widgetsopts-widgets-search")&&t(".widgetopts-chooser-sidebars li:not(:first)").removeClass("widgetopts-chooser-selected"),e.preventDefault(),e.stopPropagation(),!1}),t(".widgets-chooser").prepend(widgetopts10n.search_form),t(".widgets-chooser").liveFilter("#widgetopts-search-chooser",".widgets-chooser-sidebars li",{after:function(e,s){s.each(function(){t(this).addClass("widgetopts-is-hidden").removeClass("widgets-chooser-selected")}),e.each(function(){t(this).removeClass("widgetopts-is-hidden").removeClass("widgets-chooser-selected")}),e.length>0&&t(e[0]).addClass("widgets-chooser-selected")}}))},do_chooser:function(s,i){var o=this;t("#widgets-right .widgets-holder-wrap").each(function(e,s){var o=t(s),d=o.find(".sidebar-name h2").text(),n=o.find(".widgets-sortables").attr("id"),a=t('<li tabindex="0">').text(d.trim());0===e&&a.addClass("widgetopts-chooser-selected"),i.append(a),a.attr("data-sidebarId",n)}),e.on("click",".widgetopts-control",function(e){var d=t(this).text(),n=t(this).attr("data-action");t(this).hasClass("widgetopts-control-open")?(o.closeChooser(),t(".widgetopts-control-open").removeClass("widgetopts-control-open")):(s.find(".widgetopts-chooser-action span").text(d),s.find(".widgetopts-chooser-action").attr("data-action",n),t(this).parents(".widget-control-actions").find(".clear").after(s),s.slideDown(300,function(){i.find(".widgets-chooser-selected").focus()}),t(".widgetopts-control-open").removeClass("widgetopts-control-open"),t(this).addClass("widgetopts-control-open"),o.chooserSearch()),e.preventDefault()}),e.on("click",".widgetopts-chooser-sidebars li",function(){i.find(".widgetopts-chooser-selected").removeClass("widgetopts-chooser-selected"),t(this).addClass("widgetopts-chooser-selected")}),e.on("click",".widgetsopts-chooser .widgetopts-chooser-action",function(e){var s=t("html,body"),i=t(this).attr("data-action"),o=t(this).parents(".widgets-sortables").attr("id"),d=t(this).parents(".widget").attr("id"),n=t("#"+d);switch(sidebarID=t(".widgetopts-chooser-selected").attr("data-sidebarId"),t("#"+d+" .widgetsopts-chooser").remove(),n.find(" .widgetopts-control-open").removeClass("widgetopts-control-open"),i){case"move":t("#"+o).find("#"+d).appendTo("#"+sidebarID),t("#"+sidebarID).sortable("refresh"),n.addClass("widgetopts-move-ds"),t("#"+sidebarID).parent(".widgets-holder-wrap").removeClass("closed"),wpWidgets.save(t("#"+d),0,0,1)}var a=t(".widgetopts-move-ds");s.animate({scrollTop:a.offset().top-(s.offset().top+s.scrollTop()+60)},200),t(".widgetopts-move-ds").removeClass(".widgetopts-move-ds"),e.preventDefault()}),e.on("click",".widgetsopts-chooser .widgetsopts-chooser-cancel",function(t){o.closeChooser(s),t.preventDefault()})},closeChooser:function(){t(".widgetsopts-chooser").slideUp(200,function(){t(".widgetopts-control").removeClass("widgetopts-control-open"),t("#wpbody-content").append(this)})},chooserSearch:function(){t("#widgetsopts-widgets-search").length>0&&t(".widgetsopts-chooser").liveFilter("#widgetsopts-widgets-search",".widgetopts-chooser-sidebars li",{after:function(e,s){s.each(function(){t(this).addClass("widgetopts-is-hidden").removeClass("widgetopts-chooser-selected")}),e.each(function(){t(this).removeClass("widgetopts-is-hidden").removeClass("widgetopts-chooser-selected")}),e.length>0&&t(e[0]).addClass("widgetopts-chooser-selected")}})},sidebarOptions:function(){widgetopts10n.sidebaropts.length>0&&t("#widgets-right .widgets-holder-wrap").each(function(){var e=t(this).find(".widgets-sortables h2").text();dl_link=widgetopts10n.sidebaropts.replace("__sidebaropts__",t(this).find(".widgets-sortables").attr("id")),dl_link=dl_link.replace("__sidebar_opts__",e.trim()),t(this).append(dl_link)})},removeSidebarWidgets:function(){var s=t("html,body");e.on("click",".sidebaropts-clear",function(e){t(this).parent().find(".sidebaropts-confirm").addClass("sidebaropts-confirmed"),t(this).parent().find(".sidebaropts-confirm").slideToggle(250),e.preventDefault()}),e.on("click",".sidebaropts-confirmed .button",function(e){if(sidebar_id=t(this).parent().parent().parent().find(".widgets-sortables"),t(this).hasClass("button-primary")){var i=sidebar_id;t(this).parent().slideToggle(50),s.animate({scrollTop:i.offset().top-50},200),sidebar_id.find(".widget").each(function(e,s){t(s).fadeOut(),wpWidgets.save(t(s),1,1,0)})}else t(this).parent().slideToggle(250);e.preventDefault()})}},e.ready(function(){wpWidgetOpts.init()})}(jQuery);